<template>
  <div>
    <h1>当前求和为{{ sum }}</h1>
    <h1>当前求和值放大十倍为：{{ bigSum }}</h1>
    <h3>我在{{ school }}，学习{{ subject }}</h3>
    <select v-model.number="number">
      <!-- 或者:value -->
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
    </select>
    <button @click="addNumber(number)">+</button>
    <button @click="reduceNumber(number)">-</button>
    <button @click="oddAddNumber(number)">当前的求和值为奇数再加</button>
    <button @click="delayAddNumber(number)">等500ms后再加</button>

    <h3 style="color: red">下方人员的总人数为:{{ personList.length }}</h3>
  </div>
</template>

<script>
import { mapState, mapGetters, mapMutations, mapActions } from "vuex";
export default {
  name: "Count",
  data() {
    return {
      number: 1, //默认选中1
    };
  },
  methods: {
    ...mapMutations("countOptions", { addNumber: "JIA", reduceNumber: "JIAN" }),
    ...mapActions("countOptions", {
      oddAddNumber: "oddjia",
      delayAddNumber: "delayjia",
    }),
  },
  computed: {
    ...mapState("countOptions", {
      sum: "sum",
      school: "school",
      subject: "subject",
    }),
    ...mapState("personOptions", {
      personList: "personList",
    }),

    ...mapGetters("countOptions", ["bigSum"]),
  },
  mounted() {
    console.log(this);
  },
};
</script>

<style scoped>
button {
  margin: 0 5px 0 5px;
}
</style>